home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Text / Edit / GoldED-Demo / installdata / golded / developer / api / examples / info / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-03  |  1.7 KB  |  85 lines

  1. #include "defs.h"
  2.  
  3. /// "prototypes"
  4.  
  5. Prototype BOOL InitC(void);
  6. Prototype void ExitC(void);
  7.  
  8. ///
  9. /// "init"
  10.  
  11. /* ----------------------------------- InitC -----------------------------------
  12.  
  13.  Library startup code (C entry point). Prepare arrays which will help us to
  14.  quickly decide if a character is a white space character or a separator.
  15.  
  16. */
  17.  
  18. BOOL
  19. InitC(void)
  20. {
  21.     UWORD ascii;
  22.  
  23.     InitSemaphore(&QuickInfoSemaphore);
  24.  
  25.     NewList(&DictionaryList);
  26.  
  27.     for (ascii = 0; ascii < 256; ++ascii) {
  28.  
  29.         if (((ascii >= '0') && (ascii <= '9')) || ((ascii >= '@') && (ascii <= 'Z')) || ((ascii >= 'a') && (ascii <= 'z')) || (ascii == '_') || ((ascii >= 'À') && (ascii <= 'ÿ'))) {
  30.  
  31.             IsSPC[ascii] = FALSE;
  32.         }
  33.         else if ((ascii == '{') || (ascii == '}') || (ascii == 92)) {
  34.  
  35.             // TeX specific handling of {} and \
  36.  
  37.             IsSPC[ascii] = FALSE;
  38.         }
  39.         else
  40.             IsSPC[ascii] = TRUE;
  41.  
  42.         IsBOUNDARY[ascii] = (ascii == '(');
  43.     }
  44.  
  45.     return(TRUE);
  46. }
  47.  
  48. ///
  49. /// "exit"
  50.  
  51. /* ----------------------------------- ExitC -----------------------------------
  52.  
  53.  Library cleanup code
  54.  
  55. */
  56.  
  57. __geta4 void
  58. ExitC(void)
  59. {
  60.     // free dictionaries
  61.  
  62.     struct Dictionary *dictionary;
  63.     struct Dictionary *next;
  64.  
  65.     for (dictionary = (struct Dictionary *)DictionaryList.lh_Head; next = (struct Dictionary *)dictionary->Node.ln_Succ; dictionary = next) {
  66.  
  67.         struct Template *entry, *nextentry;
  68.  
  69.         for (entry = (struct Template *)dictionary->Entries.lh_Head; nextentry = (struct Template *)entry->Node.ln_Succ; entry = nextentry) {
  70.  
  71.             Remove(&entry->Node);
  72.  
  73.             FreeVec(entry);
  74.         }
  75.  
  76.         Remove(&dictionary->Node);
  77.  
  78.         FreeVec(dictionary->Data);
  79.  
  80.         FreeVec(dictionary);
  81.     }
  82. }
  83.  
  84. ///
  85.